options(repos="http://cran.r-project.org")
# 
# install.packages(c('foreach',
#                  'doParallel',
#                  'glmnet',
#                  'randomForest',
#                  'gbm',
#                  'nnet',
#                  'pROC',
#                  'neuralnet'))

require('devtools')
packages <- c('foreach',
              'foreign',
              'methods',
              'doParallel',
              'glmnet',
              'randomForest',
              'gbm',
              'nnet',
              'pROC',
              'neuralnet',
              'keras',
              'plm')

versions <- c(foreach="1.5.0",
              foreign="0.8.71",
              methods="3.6.0",
              doParallel="1.0.15",
              glmnet="4.0.2",
              randomForest="4.6.14",
              gbm="2.1.8",
              nnet="7.3.14",
              pROC="1.16.2",
              neuralnet="1.44.2",
              keras="2.3.0.0",
              plm="2.2.5")

for (p in packages) {
  if (packageVersion(p) == versions[p]) {
    print(paste0("Correct version of ", p))
  } else {
    install_version(package=p,
                    version=versions[p])
  }
}

require(methods)
require(foreign)
require(foreach)
require(doParallel)
require(glmnet)
require(randomForest)
require(gbm)
require(nnet)
require(pROC)
require(neuralnet)
require(keras)
